package br.com.web.utils;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

public class FacesUtils {
		
	public static void enviaMensagem(String mensagem) {
		FacesContext ctx = getContexto();
		ctx.addMessage(null, new FacesMessage(mensagem));
	}
	
	public static void destroiSessao(String mbean) {
		FacesContext ctx = getContexto();
		ctx.getExternalContext().getSessionMap().remove(mbean);
	}
	
	public static Object getSessionMapValue(String key) {
        return FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(key);
    }
	
	public static Object getApplicationMapValue(String key) {
        return FacesContext.getCurrentInstance().getExternalContext().getApplicationMap().get(key);
    }

	
	public static FacesContext getContexto() {
		return FacesContext.getCurrentInstance();	
	}

}
